import { getLevelFirst, getLevelZero } from '@/utils';

/**
 * 供应商管理权限
 * @param curRes
 * @returns
 */
const getManageTabSwitch = (curRes: Record<string, any>) => {
  if (curRes?.['/supplierInfoController/createCompanyID']) {
    return {
      createCompanyID: getLevelZero(),
      params: 'createCompanyID',
    };
  } else if (curRes?.['/supplierInfoController/createDepartmentID']) {
    return {
      createDepartmentID: getLevelFirst(),
      params: 'createDepartmentID',
    };
  }
  return {};
};

/**
 * 获取资质权限参数
 * @param curRes
 * @returns
 */
const getQualifyPaneQueqyObj = (curRes: Record<string, any>) => {
  if (curRes?.['/supplierQualifyController/createCompanyID']) {
    return {
      createCompanyID: getLevelZero(),
      params: 'createCompanyID',
    };
  } else if (curRes?.['/supplierQualifyController/createDepartmentID']) {
    return {
      createDepartmentID: getLevelFirst(),
      params: 'createDepartmentID',
    };
  }

  return {};
};

/**
 * 获取负面影响权限参数
 * @param curRes
 * @returns
 */
const getMemoirPaneQueqyObj = (curRes: Record<string, any>) => {
  if (curRes?.['/supplierMemoirController/createCompanyID']) {
    return {
      createCompanyID: getLevelZero(),
      params: 'createCompanyID',
    };
  } else if (curRes?.['/supplierMemoirController/createDepartmentID']) {
    return {
      createDepartmentID: getLevelFirst(),
      params: 'createDepartmentID',
    };
  }
  return {};
};

/**
 * 获取负面影响权限参数
 * @param curRes
 * @returns
 */
const getContactsPaneQueqyObj = (curRes: Record<string, any>) => {
  if (curRes?.['/supplierContacterController/createCompanyID']) {
    return {
      createCompanyID: getLevelZero(),
      params: 'createCompanyID',
    };
  } else if (curRes?.['/supplierContacterController/createDepartmentID']) {
    return {
      createDepartmentID: getLevelFirst(),
      params: 'createDepartmentID',
    };
  }
  return {};
};

export { getManageTabSwitch, getQualifyPaneQueqyObj, getMemoirPaneQueqyObj, getContactsPaneQueqyObj };
